package Test;

import java.util.LinkedList;
import java.util.List;

public class 全排列 {

    static List<List<Integer>> res;
    public static List<List<Integer>> permute(int[] nums) {
        LinkedList track=new LinkedList();
        back(nums,0,track);
        return  res;
    }
    static void back(int[] nums,int start,LinkedList track){
        if(track.size()== nums.length){
            res.add(track);
            return;
        }
        for(int i=0;i<nums.length;i++){
            if(track.contains(nums[i])) continue;
            track.add(nums[i]);
            back(nums,i+1,track);
            track.removeLast();
        }
    }
}